
export function checkName(name) {
  return new Promise((resolve, reject) => {
    if (!name) reject('用户名错误');
    else resolve(name);
  });
}

export function checkId(id) {
  return new Promise((resolve, reject) => {
    if (!id || id.length !== 24) reject('此话题不存在或已被删除');
    else resolve(id);
  });
}

export function checkDoc(doc) {
  return new Promise((resolve, reject) => {
    if (!doc) reject(ResultMsg.DATA_NOT_FOUND);
    else resolve(doc);
  });
}

export function checkDocs(docs) {
  return new Promise((resolve, reject) => {
    if (!docs) reject(ResultMsg.DATA_NOT_FOUND);
    else resolve(docs);
  });
}

export function checkTopicOperateLimit(authorId, isAdmin, userId) {
  return new Promise((resolve, reject) => {
    if (!isAdmin && !authorId.equals(userId)) reject('无权限');
    else resolve();
  });
}
